﻿using OS.Common.Enums;

namespace OS.Common.Core
{
    /// <summary>
    /// 自定义响应结果
    /// </summary>
    public class CustomResult
    {
        /// <summary>
        /// 返回结果代码
        /// </summary>
        public int Code { get; set; }

        /// <summary>
        /// 返回结果消息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public CustomResult()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">结果代码</param>
        /// <param name="message">消息</param>
        public CustomResult(int code, string message = "")
        {
            Code = code;
            Message = message;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="resultType">结果枚举值</param>
        /// <param name="message">消息</param>
        public CustomResult(ResultType resultType, string message = "")
        {
            Code = (int)resultType;
            Message = message;
        }
    }

    /// <summary>
    /// 自定义响应动态结果
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class CustomResult<T> : CustomResult
    {
        /// <summary>
        /// 结果类型数据
        /// </summary>
        public T Data { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public CustomResult()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="data">数据类型</param>
        public CustomResult(T data)
        {
            Data = data;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">结果代码</param>
        /// <param name="message">消息</param>
        public CustomResult(int code, string message = "")
            : base(code, message)
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="resultType">结果枚举值</param>
        /// <param name="message">消息</param>
        public CustomResult(ResultType resultType, string message = "")
            : base(resultType, message)
        {

        }
    }
}